﻿@model cloudscribe.Core.IdentityServerIntegration.Models.ApiEditViewModel
@using cloudscribe.Core.IdentityServerIntegration.Models
@using cloudscribe.Core.IdentityServerIntegration
@inject ICoreThemeHelper themeHelper
@inject IStringLocalizer<CloudscribeIds4Resources> sr
@{
    var themeSettings = themeHelper.GetThemeSettings();
    if (themeSettings.AdminSideNavExpanded) { ViewData["SideNavToggle"] = "show"; }
    ViewData["SideNavVisible"] = true;
    ApiItemViewModel currentApiModel = null;
    if(Model.CurrentApi != null)
    {
        currentApiModel = new ApiItemViewModel(Model.SiteId, Model.CurrentApi);
    }
}

@if (Model.CurrentApi == null)
{
    <h2>@ViewData["Title"]</h2>
    <partial name="NewApiPartial" model="Model.NewApi" />
}
else
{
    <h2>@ViewData["Title"]</h2>
    <partial name="EditApiResourcePartial" model="@currentApiModel" />
    <partial name="ApiScopesPartial" model="Model" />
    <partial name="ApiClaimsPartial" model="Model" />
    <partial name="ApiSecretsPartial" model="Model" />
}
@section SideNav {
    <partial name="AdminSideNav" />
}
@section Toolbar{
    <partial name="AdminSideNavToggle" />
}
@section Scripts {
    <partial name="AdminSideNavScripts" />
    <script src="~/cr/js/jquery.validate.min.js"></script>
    <script src="~/cr/js/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/cr/js/unobtrusive-validation-bs4.min.js"></script>
}
